################################################################################
#
# LLCE
#
################################################################################
# S32_LLCE_VERSION = 1.0
# S32_LLCE_SITE = $(TOPDIR)/package/vendor/nxp/s32/s32-pfe/pfeng
# S32_LLCE_SITE_METHOD := local
# S32_LLCE_INSTALL_TARGET := YES

S32_LLCE_PACKAGE_DIR = $(TOPDIR)/package/nxp/s32/s32-llce

S32_LLCE_FIRMWARE_VERSION = $(call qstrip,$(BR2_PACKAGE_S32_LLCE_FIRMWARE_VERSION))
S32_LLCE_SOC_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32_PLATFORM))
ifneq ($(S32_LLCE_SOC_PLATFORM),"s32g")
S32_LLCE_SUB_SOC_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32G_PLATFORM))
S32_LLCE_FIRMWARE_DIR = $(S32_LLCE_PACKAGE_DIR)/firmware/$(S32_LLCE_FIRMWARE_VERSION)/$(S32_LLCE_SUB_SOC_PLATFORM)
else
S32_LLCE_FIRMWARE_DIR = $(S32_LLCE_PACKAGE_DIR)/firmware/$(S32_LLCE_FIRMWARE_VERSION)/$(S32_LLCE_SOC_PLATFORM)
endif

define S32_LLCE_LINUX_CONFIG_FIXUPS
	$(if $(BR2_PACKAGE_S32_LLCE_CAN) || $(BR2_PACKAGE_S32_LLCE_CAN_MULTI_HOST),
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE,y)
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE_CONTROLLER,m))
	$(if $(BR2_PACKAGE_S32_LLCE_CAN_LOGGER),
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE_LOGGER,m))
	$(if $(BR2_PACKAGE_S32_LLCE_LINFLEX) || $(BR2_PACKAGE_S32_LLCE_LPSPI),
		$(call KCONFIG_SET_OPT,CONFIG_LLCE_CORE,m)
		$(call KCONFIG_SET_OPT,CONFIG_NXP_LLCE_MBOX,m))
endef

ifneq ($(filter y,$(BR2_PACKAGE_S32_LLCE_CAN) \
	$(BR2_PACKAGE_S32_LLCE_CAN_LOGGER) \
	$(BR2_PACKAGE_S32_LLCE_LINFLEX) \
	$(BR2_PACKAGE_S32_LLCE_CAN_MULTI_HOST)),)

define S32_LLCE_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 0755 $(S32_LLCE_FIRMWARE_DIR)/dte.bin $(TARGET_DIR)/lib/firmware/dte.bin
	$(INSTALL) -D -m 0755 $(S32_LLCE_FIRMWARE_DIR)/frpe.bin $(TARGET_DIR)/lib/firmware/frpe.bin
	$(INSTALL) -D -m 0755 $(S32_LLCE_FIRMWARE_DIR)/ppe_rx.bin $(TARGET_DIR)/lib/firmware/ppe_rx.bin
	$(INSTALL) -D -m 0755 $(S32_LLCE_FIRMWARE_DIR)/ppe_tx.bin $(TARGET_DIR)/lib/firmware/ppe_tx.bin
endef

endif

$(eval $(generic-package))
